package com.stgl.service;

import com.stgl.dao.StudentDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class StudentService {
    @Autowired
    private StudentDao studentDao;

    public List<Map<String,Object>>Search_Student(Map<String,Object>gmap)
    {
        List<Map<String,Object>>list1=studentDao.Search_Student(gmap);
        return list1;
    }

    public Map<String,Object> del_Student(Map<String,Object>gmap)
    {
        Map<String,Object>smap=new HashMap<>();
        //查询学生是否发起过报名
        List<Map<String,Object>>list1=studentDao.getStudentBmqk(gmap);
        if(list1.size()>0){
            smap.put("result",false);
            smap.put("msg","该学生已经报名,不能删除!");
        }else{
            studentDao.del_Student(gmap);
            smap.put("result",true);
            smap.put("msg","删除成功");
        }
        return smap;
    }


    public int Insert_Student(Map<String,Object>gmap)
    {
        //判断是否重复添加
        List<Map<String,Object>>list1=studentDao.ListStudentBySfz(gmap);
        if(list1.size()>0){
            return 3;
        }
       return studentDao.Insert_Student(gmap);
    }

    public int Edit_Student(Map<String,Object>gmap)
    {
        studentDao.EditUaccount(gmap);
        return studentDao.Edit_Student(gmap);
    }




    public int Insert_stufile(Map<String,Object>gmap)
    {
        return studentDao.Insert_stufile(gmap);
    }
}
